package com.example.demo.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.demo.entity.Department;
import com.example.demo.entity.Role;
import com.example.demo.mapper.DepartmentMapper;
import com.example.demo.mapper.RoleMapper;
import com.example.demo.service.DepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author moguai
 * @version 1.0
 * @date 2022/3/18 16:28
 */
@Service
public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Department> implements DepartmentService {
    @Autowired(required = false)
    DepartmentMapper departmentMapper;
    @Override
    public void InsertDepartment(Integer id, String name) {
        Department temp=new Department(id,name,System.currentTimeMillis());
        this.save(temp);
    }

    @Override
    public void UpdateDepartment(Integer id, String name) {
        Department temp=new Department(id,name,System.currentTimeMillis());
        this.updateById(temp);
    }

    @Override
    public void DeleteDepartment(Integer id) {
        departmentMapper.deleteById(id);
    }

    @Override
    public Department SelectDepartment(Integer id) {
        Department department=departmentMapper.selectById(id);
        return department;
    }
}
